<template>
	<view class="page">
		<view class="nav-back">
			<u-navbar leftText="全部分类" :autoBack="true" leftIcon="arrow-leftward" :placeholder="true"></u-navbar>
		</view>
		<view class="tabs">
			<view class="tabs-item">
				<view class="tabs-item-name" v-for="(item,index) in bigtabs" :key="index">
					<text :class="{active:!(index- menuIndex)}" @click="change(item.id,index)">{{item.name}}</text>
				</view>

			</view>
			<view class="tabs-list">
				<view class="tabs-list-box">
					<u-icon name="grid" size="55rpx"></u-icon>
				</view>
			</view>
		</view>
		<view class="container" v-show="menuIndex==menuIndex">
			<view class="container-item" v-for="(item,index) in list" :key="index" >
				<image :src="item.picUrl" mode=""></image>
				<view class="container-item-info">
					<u--text :text="item.name" size="35rpx"></u--text>
					<u--text :text="item.rcmdtext" color="#999"></u--text>
					<view class="container-item-info-fun">
						<u--text :text="item.programCount" prefixIcon="facebook" color="#999"></u--text>
						<u--text :text="item.playCount" prefixIcon="play-right" color="#999"></u--text>
					</view>
				</view>
			</view>
		</view>

	</view>
</template>

<script>	
	import {
		_getDjCatelist,
		_getRadioHot
	} from '@/http/podcast.js'
	export default {
		data() {
			return {
				bigtabs: [],
				ids: 3,
				current: 0, //下标值
				menuIndex: 0,
				list: [],
			};
		},
		methods: {

			change(id, index) {
				this.menuIndex = index
				this.ids = id
			},
			async Catelist() {
				const {
					categories
				} = await _getDjCatelist()
				this.bigtabs = categories
			},
			async djType() {
				const {
					djRadios = []
				} = await _getRadioHot(this.ids)
				this.list = djRadios
			},

		},
		created() {
			this.Catelist()
			this.djType()
		}
	}
</script>

<style lang="scss" scoped>
	.active {
		background-color: #fd5f5f;
	}

	.tabs {
		// padding: 0 30rpx;
		display: flex;
		justify-content: space-between;

		&-item {
			white-space: nowrap;
			overflow-x: scroll;
			display: flex;


			&-name {
				display: flex;
				align-content: center;
				justify-content: center;
				padding-right: 45rpx;
			}

			text {
				padding: 0rpx 30rpx;
				font-size: 15rpx;
				border-radius: 50rpx;
				display: flex;
				align-items: center;
			}
		}

		&-list {
			width: 135rpx;
			height: 55rpx;
			margin-right: 50rpx;

			&-box {

				position: absolute;
				right: 20rpx;
				display: flex;
				align-items: center;
				justify-content: center;
			}
		}
	}
	
	.container{
		padding:0 30rpx;
		
		&-item{
			margin-top: 30rpx;
			display: flex;
			
			image{
				width: 160rpx;
				height: 160rpx;
				border-radius: 15rpx;
			}
			
			&-info{
				margin-left: 15rpx;
				display: flex;
				flex-direction: column;
				flex: 1;
				
				&-fun{
					display: flex;
					font-size: 15rpx;
				}
			}
		}
	}
</style>
